package com.thti.mecool.client.adapter;

import java.util.List;

import android.app.Activity;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import com.thti.mecool.client.activity.R;
import com.thti.mecool.client.model.po.PlanCategory;

public class PlanListViewAdapter extends BaseAdapter {

	private Context mContext;
    private List<PlanCategory> listAdapter;
    private int[] images ={R.drawable.mecool_plan_add_plan,R.drawable.mecool_plan_my_plan,R.drawable.mecool_plan_draft};
	public PlanListViewAdapter(Context context,List<PlanCategory> listAdapter){
		this.mContext=context;
		this.listAdapter=listAdapter;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return listAdapter.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return listAdapter.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View view =((Activity) mContext).getLayoutInflater().inflate(R.layout.mecool_plan_item,null);
		ImageView imageView;
		TextView textView,textnumber;
		
		try {
			imageView=(ImageView)view.findViewById(R.id.mecool_plan_item_image);
			view.setTag(position);
			textView=(TextView)view.findViewById(R.id.mecool_plan_item_text);
			textnumber=(TextView)view.findViewById(R.id.mecool_plan_item_number);
			imageView.setImageResource(images[position]);
			if(position==1||position==2){
				textnumber.setVisibility(View.VISIBLE);
			}
			textView.setText(listAdapter.get(position).getCategoryName());
//			textnumber.setText(listAdapter.get(position).getCategoryNumber());
		} catch (Exception e) { 

		}
		return view;
	}

}
